package com.glory.hzlionpda.dialog;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.glory.hzlionpda.R;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_StaticMembers;


/**
 * @author jaxhuang
 * @date 2017/9/27
 * @desc
 */

public class WarnPop extends PopupWindow {

    private TextView tvTips, tvCancel, tvConfirm;

    public WarnPop(Activity context, String string, String color) {
        super(context);

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View mView = inflater.inflate(R.layout.free_ui_blue_sky_dialog_with_confirm_and_cancel, null);
        tvTips = mView.findViewById(R.id.tvTips);
        tvConfirm = mView.findViewById(R.id.tvConfirm);
        tvCancel = mView.findViewById(R.id.tvCancel);
        tvCancel.setVisibility(View.GONE);
        tvConfirm.setText("我知道了");
        switch (color.toLowerCase()) {
            case "green":
                tvTips.setTextColor(context.getResources().getColor(R.color.colorGreen));
                break;
            case "black":
                tvTips.setTextColor(context.getResources().getColor(R.color.free_ui_white));
                break;
            case "red":
                tvTips.setTextColor(context.getResources().getColor(R.color.free_ui_fire_red_theme_color));
                break;
            default:
                tvTips.setTextColor(context.getResources().getColor(R.color.free_ui_fire_red_theme_color));
                break;
        }
        // 设置按钮监听
        tvTips.setText(string);

        //设置PopupWindow的View
        this.setContentView(mView);
        //设置PopupWindow弹出窗体的宽
        this.setWidth((int) (FreeApi_StaticMembers.SCREEN_WIDTH * 0.8));
        //设置PopupWindow弹出窗体的高
        this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        //设置PopupWindow弹出窗体可点击
        this.setFocusable(false);
        this.setOutsideTouchable(false);
        //设置SelectPicPopupWindow弹出窗体动画效果
        this.setAnimationStyle(R.style.BottomDialog);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0xb0000000);
        //设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(dw);
    }

    public void setOnlickListener(View.OnClickListener onclickListener) {
        tvConfirm.setOnClickListener(onclickListener);
    }
}
